package com.struc.td;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.Array;

public class TalentTree extends State{
	private Main main;
	private Texture pauseScreen;
	private Sprite bg;
	private SpriteBatch sb;
	private Sprite playButton;
	private Sprite soundOnButton;
	private Sprite soundOffButton;
	private Sprite talentButton;
	private Sprite soundButton;
	public static Array<Talent> talents;
	public TalentTree(Main m) {
		talents = new Array<Talent>();
		pauseScreen = StaticTextures.pauseScreen;
		bg = new Sprite(pauseScreen, 0, 0, 512, 512);
		sb = new SpriteBatch();
		main = m;
		playButton = new Sprite(StaticTextures.playbutton);
		talentButton = new Sprite(StaticTextures.talentbutton);
		soundOnButton = new Sprite(StaticTextures.soundon);
		soundOffButton = new Sprite(StaticTextures.soundoff);
		soundOnButton.setBounds(0,0,30,30);
		soundOffButton.setBounds(0,0,30,30);
		playButton.setBounds(0,Gdx.graphics.getHeight()-30,30,30);
		
		talents.add(new Talent("Gold, lots of it!", new Sprite(StaticTextures.talent_goldlotsofit), false));
	}
	// makes sure the menu is where it should be.
	public void update() {
		bg.setBounds(0,0,Gdx.graphics.getWidth(),Gdx.graphics.getHeight());
		if (Sounds.getMuted()) {
			soundButton = soundOnButton;
		} else {
			soundButton = soundOffButton;
		}
	}
	
	public void render() {
		main.getState(2).render();
		sb.begin();
		bg.draw(sb);
		playButton.draw(sb);
		soundButton.draw(sb);
		talents.get(0).getSprite().setBounds(60, 120, 40, 40);
		talents.get(0).getSprite().draw(sb); 
		talents.get(0).getCheckbox().setBounds(180, 120, 40, 40);
		talents.get(0).getCheckbox().draw(sb);
		sb.end();
	}

	public void enter() {
		Gdx.input.setInputProcessor(this);
	}

	public boolean keyDown(int arg0) {
		return false;
	}

	public boolean keyTyped(char arg0) {
		return false;
	}

	public boolean keyUp(int arg0) {
		return false;
	}

	public boolean scrolled(int arg0) {
		return false;
	}

	public boolean touchDown(int x, int y, int arg2, int arg3) {
		y = Gdx.graphics.getHeight()-y;
		if (playButton.getBoundingRectangle().contains(x,y)) {
			main.setState(2);
		}
		if (soundButton.getBoundingRectangle().contains(x,y)) {
			Sounds.mute();
		}
		if (talents.get(0).getCheckbox().getBoundingRectangle().contains(x,y)) {
			talents.get(0).toggle();
		}
		return false;
	}
	
	public boolean touchDragged(int arg0, int arg1, int arg2) {
		return false;
	}

	public boolean touchMoved(int arg0, int arg1) {
		return false;
	}

	public boolean touchUp(int arg0, int arg1, int arg2, int arg3) {
		return false;
	}


}
